﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


/**
 * Lists towns in Iceland. It is dependant on the ZipCodes class
 * as base. Takes all towns with zip code and lists them
 * out. 
 * 
 * @author Ingi Gauti Ragnarsson
 */
namespace Is.Net.Country {
	public class Town {

		public string Name { get; set; }
	}

	public class Towns {

		public static List<Town> GetTowns() {
			var towns = new List<Town>();

			var zipCodes = (from z in ZipCodes.GetZipCodes()
							where !z.POBox
							group z by z.Name into g
							orderby g.Key
							select g).ToList();
			foreach (var zipCode in zipCodes) {
				towns.Add(
					new Town() {
						Name = zipCode.Key
					});

			}
			return towns;
		}
	}
}
